/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	PhysicsSystem.h
*
*	Description -	Physics System...?
*
*	Comments	-
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	08/24/2013	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_PHYSICS_SYSTEM_H_
#define _PSX_PHYSICS_SYSTEM_H_

#include "PulseSTD.h"
#include "List.h"
#include "Vector3.h"
#include "SmartPointer.h"

namespace Pulse
{
	void PhysicsDummyFunction( void );

	IPhysicsSystem * CreatePhysicsSystem( void );

	void DestroyPhysicsSystem( IPhysicsSystem *pPhysicsSys );

	struct CollisionData
	{

		// NOTE: Used for container sorting. Nothing else.
		const bool operator < ( const CollisionData &rhs ) const
		{
			return pContactBody < rhs.pContactBody;
		}

		// NOTE: Used for container sorting. Nothing else.
		const bool operator == ( const CollisionData &rhs ) const
		{
			return pContactBody == rhs.pContactBody;
		}

		// NOTE: Used for container sorting. Nothing else.
		const bool operator != ( const CollisionData &rhs ) const
		{
			return !((*this) == rhs);
		}

		typedef List<const Vector3> CollisionPointList;

		struct SharedData
		{
			CollisionPointList	collisionPoints;
			Vector3				totalNormalForce;
			Vector3				totalFrictionForce;
		};

		typedef SmartPointer<SharedData> SharedDataPtr;

		const ComponentPhysics	*pContactBody;
		SharedDataPtr			pSharedData;
	};

	struct PhysicsMaterial
	{
		PhysicsMaterial( const FLOAT _bounciness, const FLOAT _friction )
			: bounciness( _bounciness ), friction( _friction )
		{
		}

		FLOAT bounciness;
		FLOAT friction;
	};

	class IPhysicsSystem
	{
	public:

		IPhysicsSystem( void ) { }

		virtual ~IPhysicsSystem( void) { }

		virtual EErrorCode::Type Initialize( void ) = 0;

		virtual void Update( const FLOAT dt ) = 0;

		// Updating the Physics Component
		virtual EErrorCode::Type ConfigureBoxCollider( ComponentPhysics *pCompPhys ) = 0;

		virtual void RemoveComponentCollider( ComponentPhysics *pCompPhys ) = 0;

	protected:

	};
}

#endif /* _PSX_PHYSICS_SYSTEM_H_ */